<template>
  <div class="bus-layout">
    <div class="bus-title">
      <h2 class="bus-title-txt">{{busResult.progressTitle[current]}}</h2>
    </div>
    <div class="bus-step">
      <Steps :current="current">
        <Step @click.native="mutCurrent(-1)"></Step>
        <Step @click.native="mutCurrent(0)"></Step>
        <Step @click.native="mutCurrent(1)"></Step>
      </Steps>
    </div>
    <busStart v-if="current===0"></busStart>
    <busStyle v-if="current===1"></busStyle>
    <busDetail v-if="current===2"></busDetail>
  </div>
</template>
<script>
  import busStart from './views/busStart.vue'
  import busStyle from './views/busStyle.vue'
  import busDetail from './views/busDetail.vue'
  import { mapState, mapMutations } from 'vuex'

  export default {
    data () {
      return {
        busCurrent: JSON.parse(sessionStorage.getItem('current'))
      }
    },
    computed: {
      ...mapState('bus', ['current', 'busResult'])
    },
    components: {busStart, busStyle, busDetail},
    created () {
      if (this.busCurrent) {
        this.mutCurrent(this.busCurrent - 1)
      }
      // 获取dataId
      this.getDataId()
    },
    methods: {
      ...mapMutations('bus', ['mutCurrent']),
      // 获取dataId
      getDataId () {
        let dataId = JSON.parse(sessionStorage.getItem('dataId'))
        if (!dataId && dataId !== 0) {
          this.$Modal.confirm({
            title: '提示',
            content: '请先配置前置条件信息',
            onOk: () => {
              this.$router.push('/initialization')
            },
            onCancel: () => {
              this.$Message.info('点击了取消')
            }
          })
        }
      }
    }
  }
</script>
